<template>
  <div class="bg-white rounded-lg p-5 h-full">
    <div class="font-bold text-lg mb-4">医疗机构记分记录</div>

    <el-form
      :model="queryParams"
      ref="queryForm"
      size="small"
      :inline="true"
      v-show="showSearch"
    >
      <el-form-item prop="enterpriseName">
        <el-input
          v-model="queryParams.enterpriseName"
          placeholder="请输入医疗机构名称"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>

      <el-form-item prop="reason">
        <el-input
          v-model="queryParams.reason"
          placeholder="请输入记分原因"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
    </el-form>

    <div class="mb-4">
      <el-button type="primary" @click="toEditPage">添加</el-button>
      <el-button type="primary" @click="handleQuery">搜索</el-button>
      <el-button @click="resetQuery">重置</el-button>
    </div>

    <el-table v-loading="loading" :data="scoringList" border>
      <el-table-column type="index" width="55" align="center" label="序号" />
      <el-table-column
        label="医疗机构名称"
        align="center"
        prop="enterpriseName"
      />
      <el-table-column label="记分数值" align="center" prop="scoring" >
        <template slot-scope="scope">
          <div>{{ scope.row.scoring }}分</div>
         </template>
        </el-table-column>
      <el-table-column label="记分原因" align="center" prop="reason" />
     
    </el-table>

    <pagination
      v-show="total > 0"
      :total="total"
      :page.sync="queryParams.pageNum"
      :limit.sync="queryParams.pageSize"
      @pagination="getDataList"
    />
  </div>
</template>

<script>
import { getOrgScoringListAPI } from "@/api/zhangping/health-care/org-scoring";

export default {
  data() {
    return {
      // 遮罩层
      loading: true,
      // 选中数组
      ids: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      // 医疗机构计分记录表格数据
      scoringList: [],
      // 弹出层标题
      title: "",
      // 是否显示弹出层
      open: false,
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        enterpriseName: null,
        creditCode: null,
        scoring: null,
        reason: null,
        createId: null,
        updateId: null,
        startTime: "",
        endTime: "",
      },
      // 表单参数
      form: {},
      // 表单校验
      rules: {},
      detailForm: {},
      isEdit: false,
      editVisible: false,
      datePickerTime: [],
    };
  },
  created() {
    this.getDataList();
  },
  methods: {
    toEditPage() {
      const obj = {
        path: "/health-care/org-scoring-edit",
        type:0
      };
      this.$router.push(obj);
    },
    /** 查询医疗机构计分记录列表 */
    getDataList() {
      this.loading = true;

      this.queryParams.startTime = this.datePickerTime ? this.datePickerTime[0] : "";
      this.queryParams.endTime = this.datePickerTime ? this.datePickerTime[1] : "";
      getOrgScoringListAPI(this.queryParams)
        .then((response) => {
          this.scoringList = response.rows;
          this.total = response.total;
        })
        .finally(() => {
          this.loading = false;
        });
    },
    // 取消按钮
    cancel() {
      this.open = false;
      this.reset();
    },
    // 表单重置
    reset() {
      
      this.resetForm("form");
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getDataList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.datePickerTime = [];
      this.resetForm("queryForm");
      this.handleQuery();
    },
   
    /** 新增按钮操作 */
    handleAdd() {
      this.detailForm = {};
      this.isEdit = false;
      this.editVisible = true;
    },
    handleAdd777() {
      alert("待确认页面做");
    },
    /** 修改按钮操作 */
    handleUpdate(row, type) {
      // this.reset();
      const id = row.id || this.ids;
      getScoring(id).then((response) => {
        this.detailForm = response.data;
        if (type == 1) {
          this.isEdit = true;
        } else {
          // 查看
          this.isEdit = false;
        }
        this.editVisible = true;
      });
    },
    
    
    /** 导出按钮操作 */
    handleExport() {
      this.download(
        "zpMedicalOrg/scoring/export",
        {
          ...this.queryParams,
        },
        `scoring_${new Date().getTime()}.xlsx`
      );
    },
  },
};
</script>
<style lang="scss" scoped>
.app-container {
  .tableBtnListCss {
    margin-top: 10px;
    padding-top: 10px;
  }
}
</style>
